package cn.bdqn.mybatis.dao;

import cn.bdqn.mybatis.pojo.User;
import org.apache.ibatis.annotations.Param;


import java.util.List;

public interface UserDao {
    /**
     * 查询所有用户
     * @return
     * @throws RuntimeException
     */
    List<User> getAll() throws RuntimeException;

    /**
     * 通过主键id查询用户
     * @param id
     * @return
     * @throws RuntimeException
     */
    User getUserById(Integer id) throws RuntimeException;

    /**
     * 多条件查询
     * @param user
     * @return
     * @throws RuntimeException
     */
    List<User> queryUsers(User user) throws RuntimeException;

    /**
     * 通过账号和密码查询用户
     * @param userCode
     * @param userPassword
     * @return
     * @throws RuntimeException
     */
    User getUserByLogin(@Param("userCode") String userCode, @Param("userPassword") String userPassword) throws RuntimeException;

    /**
     * 新增用户
     * @param user
     * @return
     * @throws RuntimeException
     */
    int addUser(User user) throws RuntimeException;

    /**
     * 修改用户
     * @param user
     * @return
     * @throws RuntimeException
     */
    int updateUser(User user) throws RuntimeException;

    /**
     * 批量删除用户
     * @param ids
     * @return List<Integer> ids表示删除一个或者多个
     * @throws RuntimeException
     */
    int deleteUser(List<Integer> ids) throws RuntimeException;
}
